<#setting number_format="#.##">
<#-- 导入模版定义文件-->
<#include "../template/template_editPage.ftl">
<@edit title="充值方式操作">
	<#if (supplierRechargeMode.id)??>
		<#assign isEdit = true />
	<#else>
		<#assign isAdd = true />
	</#if>
	<body class="input">
	<script type="text/javascript">
    <!--
    var setting = {
        check:{
            enable:true
        },
        data:{
            simpleData:{
                enable:true
            }
        },
        callback:{
            onNodeCreated:onNodeCreated,
            onCheck:ShowCheckNode
        }
    };

    var dataMaker = function (count) {
        var nodes = [];
        $.ajax({
            type:"POST",
            async:false,
            url:"${web_base}/recharge/area!loadAllDataZTree.htm",
            data:"",
            success:function (msg) {
                var data = eval("(" + msg + ")");
                nodes = data;
            }
        });
        nodes.push({ id:"000000", pId:-1, name:"全国", isParent:true});
        return nodes;
    }
    var showNodeCount = 0;
    function onNodeCreated(event, treeId, treeNode) {
        showNodeCount++;
    }
    function ShowCheckNode(event, treeId, treeNode) {
        var zTree = $.fn.zTree.getZTreeObj("treeDemo");
        var nodes = zTree.getCheckedNodes(true);
        var purview = "";
        var name = "";
        for (var i = 0; i < nodes.length; i++) {
            if (!nodes[i].getCheckStatus().half) {
                if (nodes[i].level == 0) {
                    purview = nodes[i].id;
                    name = nodes[i].name;
                    break;
                } else if (nodes[i].level > 0) {
                    var parentNode = nodes[i].getParentNode();
                    if (parentNode.checked && !parentNode.getCheckStatus().half) {
                        delete nodes[i];
                        continue;
                    }
                }
            }
        }
        $("#treeName").val(name);
        $("#treeNode").val(purview);
        if (purview == "") {
            for (var i in nodes) {
                if (nodes[i] != undefined && !nodes[i].getCheckStatus().half) {
                    purview += nodes[i].id + ",";
                    name += nodes[i].name + ",";
                }
            }          
        $("#treeName").val(name.substring(0,name.length-1));
        $("#treeNode").val(purview.substring(0,purview.length-1));
        }
    }
    
     function createTree() {
        var zNodes = dataMaker(1);
        showNodeCount = 0;
        $("#treeDemo").empty();
        setting.check.enable = true;
        var time1 = new Date();
        $.fn.zTree.init($("#treeDemo"), setting, zNodes);
        var time2 = new Date();
    }
     $(document).ready(function () {
        createTree();
        var ss;
        ss= $("#treeNode").val().split(",");
        var treeObj = $.fn.zTree.getZTreeObj("treeDemo");           
        for(var m=0;m<ss.length;m++){	           
	        var node = treeObj.getNodeByParam("id",ss[m]);
	        if(node!=null)
	        treeObj.checkNode(node, true, true);
           
        }
    });
    //-->	
	
	$().ready( function() {
	
		var $validateErrorContainer = $("#validateErrorContainer");
		var $validateErrorLabelContainer = $("#validateErrorContainer ul");
		var $validateForm = $("#validateForm");
		var $tab = $("#tab");        
		// Tab效果
		$tab.tabs(".tabContent", {
			tabs: "input"
		});
		
		// 表单验证
		$validateForm.validate({
			errorContainer: $validateErrorContainer,
			errorLabelContainer: $validateErrorLabelContainer,
			wrapper: "li",
			errorClass: "validateError",
			ignoreTitle: true,
			rules: {
				    "supplierRechargeMode.systemProductId": {
                    required: true               
                },					
				    "supplierRechargeMode.supplierAccountId": {
                    required: true               
                },
                "minAmount": {
                    positively: true
                },
                "maxAmount": {
                    positively: true
                }
			},
			messages: {	
				"supplierRechargeMode.systemProductId":{
                    required: "挂接的系统产品不为空"
                },
				"supplierRechargeMode.supplierAccountId":{
                    required: "供货商不为空"
                },
                "minAmount": {
                    positively: "最小金额必须为大于0的数字！"
                },
                "maxAmount": {
                    positively: "最大金额必须为大于0的数字！"
                }	
			},
			submitHandler: function(form) {
				$(form).find(":submit").attr("disabled", true);
				form.submit();
			}
		}); 
		  
		<#if actionErrors??&&(actionErrors?size > 0)>
			$.dialog({type: "warn", content: "<#list errorMessages as list>${list}<br></#list>",
			 modal: true, autoCloseTime: 3000});
		</#if>
	});	
	</script>
		<div class="body">
			<div class="inputBar">
				<h1><span class="icon">&nbsp;</span><#if isAdd??>添加充值方式<#else>编辑充值方式</#if></h1>
			</div>
			<div style="display: none;" id="validateErrorContainer" class="validateErrorContainer">
				<div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
				<ul></ul>
			</div>			
			<form id="validateForm" class="validate" method="post" action="<#if isAdd??>${web_base}/recharge/supplier_recharge_mode!addMode.htm<#else>${web_base}/recharge/supplier_recharge_mode!editMode.htm</#if>">
			<table class="inputTable tabContent">
			<tr <#if isAdd??>style="display:none"</#if>>
				<th>名称:<input type="hidden" name="supplierRechargeMode.id" value="<#if isEdit??>${(supplierRechargeMode.id)!}</#if>" ></th>
				<td>${(supplierRechargeMode.name)!}
				    <input type="hidden" name="supplierRechargeMode.treeNode" id="treeNode" value="${(supplierRechargeMode.treeNode)!}">
				    <input type="hidden" name="supplierRechargeMode.treeName" id="treeName" value="${(supplierRechargeMode.treeName)!}"></td>
			</tr>
			<tr>
				<th>挂接的系统产品:</th>
				<td><select name="supplierRechargeMode.systemProductId">
				    <option value="">请选择</option>
				    <#if supplierRechargeMode??&&supplierRechargeMode.productList??>
					<#list supplierRechargeMode.productList as row>
					<option value="${(row.id)!}" <#if isEdit??><#if supplierRechargeMode.systemProductId?default("")=="${(row.id)!}" >selected="selected"</#if></#if>>${(row.name)!}</option>
					</#list>
					</#if>
				    </select><label class="requireField">*</label></td>
			</tr>
			<tr>
				<th>供应商账号:</th>
				<td><select name="supplierRechargeMode.supplierAccountId">
				    <option value="">请选择供应商账号</option>
				    <#if supplierRechargeMode??&&supplierRechargeMode.accountList??>
					<#list supplierRechargeMode.accountList as row>
					<option value="${(row.id)!}" <#if isEdit??><#if supplierRechargeMode.supplierAccountId?default("")=="${(row.id)!}" >selected="selected"</#if></#if>>${(row.name)!}</option>
					</#list>
					</#if>
				    </select><label class="requireField">*</label></td>
			</tr>
			<tr>
				<th>可选区域:</th>
				<td><ul id="treeDemo" class="ztree"></ul></td>			
			</tr>
			<tr>
				<th>相关业务</th>
				<td><input type="checkbox" name="supplierRechargeMode.enableQuery" value="<#if isEdit??>${supplierRechargeMode.enableQuery?string('true','false')}</#if>"
				    <#if isEdit??><#if supplierRechargeMode.enableQuery?string('true','false')=="true" >checked="checked"</#if></#if>>允许查询
					<input type="checkbox" name="supplierRechargeMode.enableRecharge" value="<#if isEdit??>${supplierRechargeMode.enableRecharge?string('true','false')}</#if>"  
					<#if isEdit??><#if supplierRechargeMode.enableRecharge?string('true','false')=="true" >checked="checked"</#if></#if> >允许充值
					<input type="checkbox" name="supplierRechargeMode.enableReverse" value="<#if isEdit??>${supplierRechargeMode.enableReverse?string('true','false')}</#if>" 
					<#if isEdit??><#if supplierRechargeMode.enableReverse?string('true','false')=="true" >checked="checked"</#if></#if> >是否允许冲正
				    <input type="checkbox" name="supplierRechargeMode.enableAdjustment" value="<#if isEdit??>${supplierRechargeMode.enableAdjustment?string('true','false')}</#if>" 
				    <#if isEdit??><#if supplierRechargeMode.enableAdjustment?string('true','false')=="true" >checked="checked"</#if></#if> >是否允许调账
				    <input type="checkbox" name="supplierRechargeMode.enablePointRecharge" value="<#if isEdit??>${supplierRechargeMode.enablePointRecharge?string('true','false')}</#if>" 
				    <#if isEdit??><#if supplierRechargeMode.enablePointRecharge?string('true','false')=="true" >checked="checked"</#if></#if> >是否允许带小数位缴费
				</td>
			</tr>
			<tr>
				<th>是否启用:</th>
				<td><select name="supplierRechargeMode.enable">
				    <option value="false" <#if isEdit??><#if supplierRechargeMode.enable?string('true','false')=="false">selected="selected"</#if></#if> >否</option>
					<option value="true"  <#if isEdit??><#if supplierRechargeMode.enable?string('true','false')=="true">selected="selected"</#if></#if> >是</option>
				    </select>
				</td>
			</tr>	
			<tr>
				<th>最小面额:</th>
				<td><input type="text" class="formText" name="minAmount" value="${money((supplierRechargeMode.minAmount)!)}" ></td>
			</tr>
	
			<tr>
				<th>最大限额:</th>
				<td><input type="text" class="formText" name="maxAmount" value="${money((supplierRechargeMode.maxAmount)!)}" ></td>
			</tr>
			<tr>
				<th>到账时间:</th>
				<td><input type="text" class="formText" name="supplierRechargeMode.arriveTime" value="${(supplierRechargeMode.arriveTime)!}" ></td>
			</tr>
			<tr>
				<th>可充值时间设置:</th>
				<td><input type="text" id="startTime" name="startTime" onfocus="WdatePicker({readOnly:true,dateFmt:'HH:mm:ss'})" 
				    <#if supplierRechargeMode.startTime?exists&&supplierRechargeMode.startTime?is_date> 
				    value="${(supplierRechargeMode.startTime)?string("HH:mm:ss")}"</#if> class="Wdate">-
				    <input type="text" id="endTime" name="endTime" onfocus="WdatePicker({readOnly:true,dateFmt:'HH:mm:ss'})" 
				    <#if supplierRechargeMode.endTime?exists&&supplierRechargeMode.endTime?is_date> 
				    value="${(supplierRechargeMode.endTime)?string("HH:mm:ss")}"</#if> class="Wdate">
				    (可不填时间格式10:20:00)</td>
			</tr>			
			<tr>
				<th>备注:</th>
				<td><textarea class="formText" name="supplierRechargeMode.comment">${(supplierRechargeMode.comment)!}</textarea></td>
			</tr>
			</table>
			<div class="buttonArea">
				<input type="submit" class="formButton" value="<#if isAdd??>添加<#else>修改</#if>" hidefocus="true" />&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" class="formButton" onclick="window.history.back(); return false;" value="返  回" hidefocus="true" />
			</div>
			</form>
		</div>
	</body>

</@edit>